home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/stat.h>
- #include <io.h>
- #include <fcntl.h>
-
- #include "aspi.h"
- #include "tape.h"
-
- unsigned block_size = 20*512U;
- unsigned char *buffer;
-
- int data_f;
-
- void do_write(void)
- {
- char cdb[6];
- int stat, i, c;
- long minblock, maxblock;
- unsigned long total = 0;
-
- tape_rewind(1);
- tape_set_blocksize(block_size);
-
- while (1)
- {
- int r = read(data_f, buffer, block_size);
- if (r < 0)
- {
- perror("While reading data file");
- return;
- }
- if (r == 0)
- break;
- memset(buffer+r, 0, block_size-r);
- tape_write(buffer);
-
- total += r;
- printf(" %s\r", tape_fmtnum(total));
- fflush(stdout);
- }
- printf("\n");
-
- tape_write_filemark(3, 0);
- }
-
- int main(int argc, char **argv)
- {
- int target;
- int stat;
-
- if (argc < 2)
- {
- printf("datwrite [-b blocks(512ea)] file\n");
- printf(" ex: blocks = 20 is 10K\n");
- return -1;
- }
-
- if (strcmp(argv[1], "-b") == 0)
- {
- block_size = atoi(argv[2]) * 512UL;
- argc -= 2;
- argv += 2;
- }
-
- data_f = open(argv[1], O_RDONLY|O_BINARY);
- if (data_f < 0)
- {
- perror("Opening input data file");
- exit(1);
- }
-
- buffer = (char *)malloc(block_size);
- aspi_buffer_length = block_size;
- tape_open();
- do_write();
- tape_close();
-
- close(data_f);
- return 0;
- }
-